<?php namespace system\model;
use Hdphp\Model\Model;
class Type extends Model{
    //操作数据表
    protected $table = 'type';
    //自动验证
    protected $validate = [
      ['tname','required','请输入类型名称',3,3],
    ];
    //类型首页
    public function getAll(){
        $page = Page::row(6)->make($this->count());

        $data = $this->limit(page::limit())->get();
        //p($page);die;
        return ['page'=>$page,'data'=>$data];
    }
    //添加类型
    public function store(){
      //执行自动验证
      if(!$this->create()) return false;
      //执行添加
      return $this->add();
    }
    //类型编辑
    public function edit(){
       if(!$this->create()) return false;

        return $this->save();

    }

}